package cn.lcsjsxy.yxz.day.Thread;

//线型执行方式(串行与并行)
public class Serialandparallel {
    public static void main(String[] args) throws Exception {

        //串行执行:多个线程连接成串，然后按照循序执行
        //并发执行,多个线程是独立的,谁抢到就是谁

        MyThread2 t1 = new MyThread2();
        MyThread3 t2 = new MyThread3();

        t1.start();
        t2.start();

        //将线程连接成串
        t1.join();
        t2.join();

        System.out.println("main线程程序执行完毕!!!");
    }

}

    //第一个线程
class MyThread2 extends Thread {
    //重写运行指令
    @Override
    public void run() {
        System.out.println("MyThread-1: " + Thread.currentThread().getName());

    }
}
    //第二个线程
class MyThread3 extends Thread {
    //重写运行指令
    @Override
    public void run() {
        System.out.println("MyThread-2: " + Thread.currentThread().getName());

    }
}